import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class LoginDialog_Database extends Dialog {
  private JPanel panel = new JPanel();
  private Label label1 = new Label();
  private Label label2 = new Label();
  private TextField dataUser = new TextField();
  private TextField dataPassword = new TextField();
  private Button tombol_Login = new Button();

  public static void main(String[] args) {
    LoginDialog_Database login = new LoginDialog_Database();
    login.setSize(250, 150);
    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    int lebar = (screen.width - login.getSize().width) / 2;
    int tinggi = (screen.height - login.getSize().height) / 2;
    login.setLocation(lebar, tinggi);
    login.setResizable(false);
    login.setVisible(true);
  }

  public LoginDialog_Database() {
    super(new Frame(), "Login dengan Database", true);
    panel.setLayout(null);
    label1.setText("Nama User :");
    label1.setAlignment(Label.RIGHT);
    label1.setBounds(new Rectangle(0, 9, 77, 22));
    label2.setBounds(new Rectangle(0, 37, 77, 22));
    label2.setText("Password :");
    label2.setAlignment(Label.RIGHT);
    dataUser.setText("");
    dataUser.setBounds(new Rectangle(84, 11, 144, 20));
    dataPassword.setEchoChar('*');
    dataPassword.setText("");
    dataPassword.setBounds(new Rectangle(84, 41, 144, 20));
    tombol_Login.setLabel("L O G I N");
    tombol_Login.setBounds(new Rectangle(72, 77, 86, 24));
    tombol_Login.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        tombol_Login();
      }
    });
    panel.setBackground(SystemColor.info);
    panel.add(label2);
    panel.add(label1);
    panel.add(dataUser);
    panel.add(dataPassword);
    panel.add(tombol_Login);
    this.add(panel);
  }

  void tombol_Login() {
    dispose();
    String user = dataUser.getText();
    String password = dataPassword.getText();
    proses_Login proses = new proses_Login(user, password);
    proses.setSize(350, 100);
    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    int lebar = (screen.width - getSize().width) / 2;
    int tinggi = (screen.height - getSize().height) / 2;
    proses.setLocation(lebar, tinggi);
    proses.setVisible(true);
  }
}